local modid = 'yuemiheng'
if TUNING[string.upper('CONFIG_'..modid..'_quickbuild')] then
    local rules = {
        ACTIONS.BUILD,
    }
    local avatar_name = 'yuemiheng'

    AddStategraphPostInit("wilson", function(sg)
        for _, v in pairs(rules) do
            local taraction = v
            local original_handler = sg.actionhandlers[taraction] and sg.actionhandlers[taraction].deststate
            local actionhandler = GLOBAL.ActionHandler(taraction, function(inst, action, ...)
                local doer = action.doer
                if doer and doer:HasTag("player") and doer:HasTag(avatar_name) then
                    return "doshortaction"
                end
                return original_handler and original_handler(inst, action, ...) or nil
            end)
            sg.actionhandlers[taraction] = actionhandler
        end
    end)

    AddStategraphPostInit("wilson_client", function(sg)
        for _, v in pairs(rules) do
            local taraction = v
            local original_handler = sg.actionhandlers[taraction] and sg.actionhandlers[taraction].deststate
            local actionhandler = GLOBAL.ActionHandler(taraction, function(inst, action, ...)
                local doer = action.doer
                if doer and doer:HasTag("player") and doer:HasTag(avatar_name) then
                    return "doshortaction"
                end
                return original_handler and original_handler(inst, action, ...) or nil
            end)
            sg.actionhandlers[taraction] = actionhandler
        end
    end)
end
